aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/invoice/[id]/+layout.server.ts
diff options
context:
space:
mode:
authorJurjen de Vries <[email protected]>2025-09-11 00:48:15 +0200
committerGitHub <[email protected]>2025-09-11 00:48:15 +0200
commit0c69c9848c6b98c92609d209103efc60003c9723 (patch)
tree445121def885f13d0f80c06864ad2ff4d5ef95a1 /src/routes/(app)/invoice/[id]/+layout.server.ts
parent2abcf6e435fca5d86960f3ba4228002bfb0a19e6 (diff)
parent9277b2921e09ee9dd5f39cf4af30a2330f4d95d1 (diff)
downloadcoinos-ui-0c69c9848c6b98c92609d209103efc60003c9723.tar.gz
coinos-ui-0c69c9848c6b98c92609d209103efc60003c9723.zip
Merge branch 'coinos:master' into master
Diffstat (limited to 'src/routes/(app)/invoice/[id]/+layout.server.ts')
-rw-r--r--src/routes/(app)/invoice/[id]/+layout.server.ts26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts
index 590e5d4d..ab41dddc 100644
--- a/src/routes/(app)/invoice/[id]/+layout.server.ts
+++ b/src/routes/(app)/invoice/[id]/+layout.server.ts
@@ -12,19 +12,8 @@ export async function load({ cookies, depends, params, url, parent }) {
if (id) {
invoice = await get(`/invoice/${id}`);
const options = !!url.searchParams.get("options");
-
- if (
- user &&
- invoice.uid !== user.id &&
- !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
- !options
- ) {
- redirect(307, `/send/invoice/${id}`);
- }
-
let { amount, pending, received } = invoice;
amount = parseInt(amount);
- subject = invoice.user;
const paid =
(!amount && (pending || received)) ||
@@ -32,6 +21,21 @@ export async function load({ cookies, depends, params, url, parent }) {
if (paid && !url.pathname.endsWith("paid")) {
redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : ""));
}
+
+ subject = invoice.user;
+
+ if (
+ user &&
+ invoice.uid !== user?.id &&
+ !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
+ !options
+ ) {
+ if (invoice.prompt && invoice.tip === null)
+ redirect(307, `/invoice/${id}/tip`);
+ else {
+ redirect(307, `/send/invoice/${id}`);
+ }
+ }
}
const theme = cookies.get("theme") || "light";